import { getAction, deleteAction, putAction, postAction } from '@/api/manage';
import type loginType from '@/composables/request/instanceof/loginType'

/**
 * 热门文章
 */
const hostArticle = getAction("/article/hostArticle")
/**
 * 最新评论
 */
const newCommentList = getAction("/comment/newCommentList")
/**
 * 标签云
 */
const getTagList = getAction("/tag/getTagList")
/**
 * 首页文章列表
 */
const getArticleList = (param: any) => getAction("/article/getArticleList", param)
/**
 * 获取分类列表
 */
const getCategoryList = getAction("/category/getCategoryList")

/**
 * 根据标签ID获取文章列表
 */
const getByTagIdArticleList = (id: any) => getAction(`/article/getByTagIdArticleList/${id}`)

/**
 * 根据分类ID获取文章列表
 */
const getByCategoryIdArticleList = (id: any) => getAction(`/article/getByCategoryIdArticleList/${id}`)

/**
 * 根据内容模糊查询
 */
const getByValueArticleList = (value: any) => getAction(`/article/getByValueArticleList/${value}`)
/**
 * 获取文章
 */
const getArticle = (id: any) => getAction(`/article/getArticle/${id}`)

/**
 * 登录
 */
const Adminlogin = (param: loginType) => postAction(`/login`, param)

/**
 * 后台
 */
const  adminGetArticleList = (param: any) => getAction("/admin/article",param);
/**
 * 根据Id获取文章
 * @param id
 */
const  adminGetArticle = (id: any) => getAction(`/admin/article/${id}`)

/**
 * 根据Id删除文章
 * @param id
 */
const  adminDelArticle = (id: any) => deleteAction(`/admin/article/${id}`)
/**
 * 新增文章
 * @param param
 */
const  createArticle = (param:any) => postAction('/admin/article',param)
/**
 * 修改文章
 * @param param
 * @param id
 */
const  updateArticle = (param:any,id:any) => putAction(`/admin/article/${id}`,param)

/**
 * 获取分类列表
 * @param param
 */
const  adminGetCategoryList = (param:any) => getAction(`/admin/category/`,param)
/**
 * 根据ID删除分类
 * @param id
 */
const  adminDelCategory = (id:any) => deleteAction(`/admin/category/${id}`)
/**
 * 根据ID获取分类
 * @param id
 */
const  adminGetCategory = (id:any) => getAction(`/admin/category/${id}`)
/**
 * 根据ID获取分类
 * @param param
 * @param id
 *
 */
const  adminEditCategory = (param:any,id:any) => putAction(`/admin/category/${id}`,param)
/**
 * 新增分类
 * @param param
 */
const  adminAddCategory = (param:any) => postAction(`/admin/category/`,param)

const  adminGetTagList = (param:any) => getAction(`/admin/tag/`,param)




export {
    hostArticle,
    newCommentList,
    getTagList,
    getArticleList,
    getCategoryList,
    getByTagIdArticleList,
    getByCategoryIdArticleList,
    getByValueArticleList,
    getArticle,
    Adminlogin,
    adminGetArticleList,
    adminGetArticle,
    createArticle,
    updateArticle,
    adminDelArticle,
    adminGetCategoryList,
    adminDelCategory,
    adminGetCategory,
    adminEditCategory,
    adminAddCategory,
    adminGetTagList
}